﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Workflows.Components.Entities.Providers;

namespace Workflows.Components.Entities.Relations.DirectAssociations 
{
    public abstract class Relation
    {
        private EntityMetaData _SrcMetaData;
        /// <summary></summary>
        public EntityMetaData SrcMetaData
        {
            get
            {
                return this._SrcMetaData;
            }
            set
            {
                this._SrcMetaData = value;
            }
        }

        private EntityMetaData _ReferencedMetaData;
        /// <summary></summary>
        public EntityMetaData ReferencedMetaData
        {
            get
            {
                return this._ReferencedMetaData;
            }
            set
            {
                this._ReferencedMetaData = value;
            }
        }

        private EntityReferenceType _ReferenceType;
        /// <summary></summary>
        public EntityReferenceType ReferenceType
        {
            get
            {
                return this._ReferenceType;
            }
            set
            {
                this._ReferenceType = value;
            }
        }

        private Dictionary<string,string> _MappingsFromEntity1ToEntity2;
        /// <summary></summary>
        public Dictionary<string,string> MappingsFromEntity1ToEntity2
        {
            get
            {
                return this._MappingsFromEntity1ToEntity2;
            }
            set
            {
                this._MappingsFromEntity1ToEntity2 = value;
            }
        }

        private RelationshipDirection _Direction;
        /// <summary></summary>
        public RelationshipDirection Direction
        {
            get
            {
                return this._Direction;
            }
            set
            {
                this._Direction = value;
            }
        }

        private string _RelationLabel;
        /// <summary></summary>
        public string RelationLabel
        {
            get
            {
                return this._RelationLabel;
            }
            set
            {
                this._RelationLabel = value;
            }
        }

        //private Dictionary<string,object> _RelationEvidence1;
        ///// <summary>from entity attribute name/value</summary>
        //public Dictionary<string,object> RelationEvidence1
        //{
        //    get
        //    {
        //        return this._RelationEvidence1;
        //    }
        //    set
        //    {
        //        this._RelationEvidence1 = value;
        //    }
        //}

        //private Dictionary<string,object> _RelationEvidence2;
        ///// <summary></summary>
        //public Dictionary<string,object> RelationEvidence2
        //{
        //    get
        //    {
        //        return this._RelationEvidence2;
        //    }
        //    set
        //    {
        //        this._RelationEvidence2 = value;
        //    }
        //}

        //private double _Distance;
        ///// <summary></summary>
        //public double Distance
        //{
        //    get
        //    {
        //        return this._Distance;
        //    }
        //    set
        //    {
        //        this._Distance = value;
        //    }
        //}

        //private double _Confidence;
        ///// <summary></summary>
        //public double Confidence
        //{
        //    get
        //    {
        //        return this._Confidence;
        //    }
        //    set
        //    {
        //        this._Confidence = value;
        //    }
        //}

        public Relation(EntityMetaData srcMetaData, EntityMetaData refMetaData, 
            EntityReferenceType refType, Dictionary<string,string> mappings,
            RelationshipDirection direction, string label)
        {
            this._SrcMetaData = srcMetaData;
            this._ReferencedMetaData = refMetaData;
            this._ReferenceType = refType;
            this._MappingsFromEntity1ToEntity2 = mappings;
            this._Direction = direction;
            this._RelationLabel = label;

            //this._Distance = double.NaN;
            //this._Confidence = double.NaN;
            //this._RelationEvidence1=new Dictionary<string, object>();
            //this._RelationEvidence2=new Dictionary<string, object>();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="seed"></param>
        /// <param name="srcProvider"></param>
        /// <param name="refProvider"></param>
        /// <param name="entityConnections"></param>
        public abstract void PopulateFromSeed(Entity seed, 
            EntityProvider srcProvider, EntityProvider refProvider,
            ref Dictionary<string, List<string>> entityConnections);
    }
}
